//
//  OnceViewController.m
//  YYPHSpeedJump
//
//  Created by sujiang on 15/12/16.
//  Copyright © 2015年 sujiang. All rights reserved.
//

#import "OnceViewController.h"

@interface OnceViewController ()<UIScrollViewDelegate>
{
    UIScrollView *scroll;
    UIPageControl *pageControl;
}
@end

@implementation OnceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addSubViews];
}


- (void)addSubViews
{
    scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    scroll.contentSize = CGSizeMake(3 * kScreenWidth, 0);
    scroll.pagingEnabled = YES;
    UIImageView *aView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    [scroll addSubview:aView];
    scroll.showsVerticalScrollIndicator = NO;
    scroll.showsHorizontalScrollIndicator = NO;
    scroll.bounces = NO;
    aView.image = [UIImage imageNamed:@"once3"];
    
    UIImageView *bView = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, kScreenHeight)];
    bView.image = [UIImage imageNamed:@"once2"];
    [scroll addSubview:bView];
    UIImageView *cView = [[UIImageView alloc] initWithFrame:CGRectMake(2 * kScreenWidth, 0, kScreenWidth, kScreenHeight)];
    cView.image = [UIImage imageNamed:@"once1"];
    [scroll addSubview:cView];
    cView.userInteractionEnabled = YES;
    [self.view addSubview:scroll];
    scroll.delegate = self;
    pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, kScreenHeight - 15, kScreenWidth, 15)];
    // [self.view addSubview:pageControl];
   // pageControl.backgroundColor = [UIColor blackColor];
    pageControl.numberOfPages = 3;
    pageControl.currentPage = 0;
    pageControl.pageIndicatorTintColor = kColors(255, 255, 255, 1);
    pageControl.currentPageIndicatorTintColor = kColors(218, 166, 46, 1);
    [self.view addSubview:pageControl];
   
//    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
//    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
//    effectView.alpha = 0.35;
//    effectView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
//    effectView.backgroundColor = [UIColor blackColor];

    
    UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    // [button setTitle:@"开始速降" forState:(UIControlStateNormal)];
    [button setBackgroundImage:[UIImage imageNamed:@"ksdj"] forState:(UIControlStateNormal)];
    button.frame = CGRectMake((kScreenWidth - 156 * kWidthScale) / 2, kScreenHeight - 45 *kHeightScale - 15, 156 * kWidthScale, 45 * kHeightScale);
    [cView addSubview:button];
    [button addTarget:self action:@selector(actionGo:) forControlEvents:(UIControlEventTouchUpInside)];
   // button.backgroundColor = kColors(216, 166, 46, 1);
    button.layer.cornerRadius = 5;
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    pageControl.currentPage = scrollView.contentOffset.x / kScreenWidth;
}

- (void)actionGo:(UIButton *)button
{
    AppDelegate *app = [UIApplication sharedApplication].delegate;
    [app setRootVC];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
